/**
 * Created by afer on 2017/8/19.
 */



var ICOInfo = require('./dao').ICOInfo;
module.exports = {
    create: function (icoinfo) {
        return ICOInfo.insert(icoinfo).exec();
    },

    getAllICOInfo: function () {
        return ICOInfo.find().sort({_id: -1}).addCreatedAt().exec();
    },

    getICOInfoByName: function (name) {
        var query = {};
        if (name) {
            query.name = name;
        }
        return ICOInfo.find(query).sort({_id: -1}).exec();
    },

    getICOInfoByID: function (ID) {
        var query = {};
        if (ID) {
            query._id = ID;
        }
        return ICOInfo.find(query).sort({_id: -1}).exec();
    }
}